mini.parse();
var baseUrl = "http://localhost:8080/DSMP";
var grid=mini.get("grid1");
//分页控件
var pager = grid.getBottomPager();
var form= new mini.Form("#form1");
var qqq=[
    { "id": "1", "text": "登录" },
    { "id": "2", "text": "操作" },
    { "id": "3", "text": "登出" },
]

var logType=mini.get("logType");
logType.setData(qqq);

(function(){
    request('0',pager.getPageSize());
})();



//跳转编辑页面
function editRow(){
    var row=grid.getSelected();
    console.log(row);
    if(row!=undefined){
        mini.open({

            targetWindow: window,
            url:"LogInfo.html",
            title:"日志详情",
            height:"90%",
            width:"90%",
            showMaxButton: true,
            showModal:Boolean,
            allowResize:Boolean,
            setReadOnly:true,
            onload: function () {
                var iframe = this.getIFrameEl();//备份这个跨子页面窗口
                var data = {  action: "edit",row:row};//父传值给子页面
                iframe.contentWindow.SetData(data);//跨字串后页面渲染data
            },
            ondestroy: function (action) {
                if(action=="edit"){
    
    
                }
            }
        })
    }else{
        mini.alert("请选择一条数据")
    }

}
// 删除
function removeRow(){
    var rows=grid.getSelecteds();
    console.log(rows);
    var ids=[]
    rows.forEach(function(item){
        ids.push  (item.logId)
    })
    console.log(ids);
    //carIds=JSON.stringify(ids);
    if (rows.length>0) {        //当一条都不选时提示让选一条
        console.log(ids);
        var id = grid.getSelected().logId;
        $.ajax({
            url:baseUrl+"/system/actionLog/delete.do",
            data:{ids:ids},
            type:"post",
            traditional: true,
            success:function (data) {
                mini.alert(data.msg)
                request();
            }
        })
    }else{
        mini.alert("请至少选中一行记录")
    }
}


//下载
function download(){
    alert("下载按钮js第136行");//这行不用请删掉
    var row=grid.getSelected();
    console.log(row);
    row=JSON.parse(row);         //将这一行值转化成字符串
        //     $.ajax({
    //     url:url,                //放接口
    //     type: "post",
    //     contentType: "application/json",
    //     data:row,
    //     success: function(data) {//请求成功完成后要执行的方法
    //         console.log(data);
    //         // grid.setData(data.data);
    //         // pager.set({"totalCount": data.total})
    //     },
    //     error:function(data){
    //         mini.alert(data);
    //     }
    // });
}
function request(pageIndex,pageSize){
    var pageIndex = pager.getPageIndex()
    var pageSize = pager.getPageSize();

    var pageObj = {
        current: pageIndex,
        size: pageSize,
    }

    var pageStr = JSON.stringify(pageObj);
    $.ajax({
        url: baseUrl+"/system/actionLog/getList.do",
        type: "post",
        contentType: "application/json",
        data:pageStr,
        success: function(data) {//请求成功完成后要执行的方法
            console.log(data);
           // data=JSON.parse(data)    //如果字符串的话，转换成json
            grid.setData(data.obj);
            pager.set({"totalCount": data.attributes.total})
        },
        error:function(data){
            mini.alert(cuole);
        }
    });
}
//根据筛选条件查询
function find(){
    var aaa=form.getData();
    aaa=JSON.stringify(aaa);
    $.ajax({
        url: baseUrl+"/system/actionLog/getListByWhere.do",
        type: "post",
        contentType: "application/json",
        data:aaa,
        success: function(data) {//请求成功完成后要执行的方法
            console.log(data);

            grid.setData('');
            grid.setData(data.obj);
            mini.after(data.msg)
        },
        error:function(data){
            mini.alert(cuole);
        }
    });
}


//分页
grid.on("beforeload", function (e) {
    //阻止本来的翻页功能
    e.cancel = true;
    //当前页码
    var cunrrentPageIndex = grid.getPageIndex();
    //点击按钮之后的页码
    var pageIndex = e.data.pageIndex;
    //设置当前页数值
    pager.set({"pageIndex": pageIndex});
    //数据总数
    //var pageCount = pubPageCount;
    pager.set({"pageIndex": pageIndex});
    request(pageIndex + 1, pager.getPageSize());
});

//刷新
function onRefresh(e) {
    list(pager.getPageIndex(), pager.getPageSize());
}


//条件查询清空条件
function clean() {
    form.reset();
}
//刷新按钮
function refresh(){
        form.reset();
        request('0',pager.getPageSize());
}